package com.wuba.rxjavademo.tzx.filter;

import com.wuba.rxjavademo.tzx.common.Base;

/**
 * Created by tanzhenxing
 * Date: 2016/6/27.
 * Description:
 * elementAt( ) — 发射第N项数据
 * elementAtOrDefault( ) — 发射第N项数据，如果Observable数据少于N项就发射默认值
 */
public class RxAboutElementAt extends Base {
    public static void main(String[] args) {
        RxAboutElementAt rxAboutElementAt = new RxAboutElementAt();
        rxAboutElementAt.run();
    }

    @Override
    public void run() {
        getObservable()
                .elementAt(1)
                .subscribe(num -> print(num, "elementAt:"));
        getObservable()
                .elementAtOrDefault(10, -1)
                .subscribe(num -> print(num, "elementAtOrDefault:"));
    }
}
